package com.example.star.controller;

import com.example.star.entity.Address;
import com.example.star.entity.Follow;
import com.example.star.service.AddressService;
import com.example.star.service.FollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
public class AddressController {
    @Autowired
    private AddressService addressService;
    @GetMapping("/address")
    @ResponseBody
    public List<Address> getAddress() {
        return addressService.getAddress();
    }

    @PostMapping("/address")
    @ResponseBody
    public Address saveAddress(@RequestBody Address address) {
        addressService.saveAddress(address);
        return address; // 返回保存的Favorite对象
    }

    @GetMapping("/address/items-by-user")
    @ResponseBody
    public List<Address> getAddressByUserName(@RequestParam("userName") String userName){
        return addressService.getAddressByUserName(userName);
    }
}
